import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/assets/css/global.css'
import '@/assets/css/theme/index.css'
import request from "@/utils/request";

Vue.config.productionTip = false

Vue.prototype.$request = request
Vue.prototype.$baseUrl = process.env.VUE_APP_BASEURL

Vue.use(ElementUI, { 
  size: 'large',
  zIndex: 3000
})

// 添加老年人模式切换监听
// 修正全局切换方法
Vue.prototype.$switchElderMode = (isElder) => {
    const root = document.documentElement
    root.classList.toggle('elder-mode', isElder)
    
    // 添加视口meta标签保证响应式适配
    const meta = document.querySelector('meta[name="viewport"]') || document.createElement('meta')
    meta.name = "viewport"
    meta.content = isElder ? 
        "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes" :
        "width=device-width, initial-scale=1.0"
    document.head.appendChild(meta)
}

// 初始化时读取状态
document.addEventListener('DOMContentLoaded', () => {
    const isElder = localStorage.getItem('elderMode') === 'true'
    Vue.prototype.$switchElderMode(isElder)
})
new Vue({
    router,
    render: h => h(App)
}).$mount('#app')
